package com.test.day04;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;

/**
 * @program: 用输入输出流复制文件
 * @author: luhd
 * @create: 2021-08-05
 */
public class CopyFile {
    /**
     *  一读一写
     */
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("D:\\myProject\\javaTest\\a.txt");
        FileOutputStream fos = new FileOutputStream("D:\\a.txt");
        int len = 0;
        while((len = fis.read())!=-1){
            fos.write(len);
        }
        //int len = 0;
        byte[] bytes = new byte[1024];
        while((len = fis.read(bytes))!=-1){
            fos.write(bytes,0,len);
        }
        fos.close();
        fis.close();
    }
}
